package com.cande.loki.exercise.testspring;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @auther ROCK CODER
 * @DATE 2022/4/17 17:52
 * @Description
 */
public class MyApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        System.out.println("====my initializer start===");
        // 自定义properties
        System.setProperty("myinit","my application context initializer");

        ConfigurableEnvironment environment = applicationContext.getEnvironment();
        environment.getSystemProperties().forEach((key, value) -> {
            System.out.println(key + "===" + value);
        });

        System.out.println("====my initializer end===");
    }
}
